<!--_meta 作为公共模版分离出去-->
{include file="common/_meta" /}
<!--/meta 作为公共模版分离出去-->


<title>添加商品</title>
<link href="__MANAGE__lib/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
</head>
<body>
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
		<span class="c-gray en">&gt;</span>
		商品管理
		<span class="c-gray en">&gt;</span>
		编辑商品
		<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);"
		 title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
	</nav>
	<style type="text/css">
		input,
		label {
			vertical-align: middle;
		}
	</style>
	<div class="page-container">
		<form action="" method="post" class="form form-horizontal" id="form-article-add" enctype="multipart/form-data">

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2">
					<span class="c-red">*</span>
					商品名称：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" id="goods_name" name="goods_name" placeholder="输出名称长度介于 3 和 200 之间" value="{$goods.goods_name}" class="input-text">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2">分类栏目：</label>
				<div class="formControls col-xs-8 col-sm-9"> <span class="select-box">
						<select name="cate_id" id="cate" class="select">
							<option value=0>选择栏目</option>
							{volist name="cate" id="vo"}
							<option {if $vo.id==$goods.cate_id}selected{/if} value="{$vo.id}">{$vo.name}</option>
							{/volist}
						</select>
					</span> </div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>产品首页主图：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<a href="javascript:void();" class="btn btn-primary radius"><i class="icon Hui-iconfont">&#xe642;</i> 浏览文件</a>
					<input type="file" class="input-file" onchange='onpic(this)' name="goods_img" value="" accept='image/*'	 style="font-size: 20px;left:0;" />
					<span class="sp"></span> <span style="color: red;margin-left: 20px;">注意：请上传图片比例为1:1。防止变形！</span>
					<div style="margin: 15px;">
					{if condition="$goods['goods_img']"}
					    <img src="{$goods.goods_img|obs}" height="50">
					{else /}
					    	暂无缩略图
					{/if}
					</div>
				</div>
			</div>
			
			
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2">
					是否上架：</label>
				<div class="formControls col-xs-9 col-sm-9">
					<div class="switch" data-on-label="开" data-off-label="关">
						<input type="checkbox" {if condition="$goods['isopen'] eq 1"} checked="checked" {/if} name="isopen"/>
					</div>
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2">市场价格：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="number" name="markte_price"  placeholder="请输入市场价格" value="{$goods.markte_price}" class="input-text" style="width:30%">
					元</div>
			</div>

			<div class="row cl ">
				<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>本店价格：</label>
				<div class="formControls col-xs-4 col-sm-4">
					<input type="number" name="money" id="" placeholder="请输入现金价格" value="{$goods.money}" class="input-text" style="width:80%">
					元</div>
			
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2">返现：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="number" name="fen_money" id="" placeholder="请输入返现价格" value="{$goods.fen_money}" class="input-text" style="width:30%">
					元</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>库存：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="number" name="kucun_num" id="" placeholder="请输入库存" value="{$goods.kucun_num}" class="input-text" style="width:30%">
					默认库存为100000</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>邮费：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="number" name="postage" id="" placeholder="请输入邮费" value="{$goods.postage}" class="input-text" style="width:30%">
					元</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>已售卖数量：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="number" name="sales_num"  placeholder="已售卖数量" value="{$goods.sales_num}" class="input-text" style="width:30%">
					随机显示 1000-5000 之间</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>产品浏览数：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="number" name="liu_num" id="" placeholder="产品浏览数" value="{$goods.liu_num}" class="input-text" style="width:30%">
					随机显示 1000-10000 之间</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2">添加属性：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" name="attr_title" id="attr_title" placeholder="输入属性标题" value="{$attr.title|default=''}" class="input-text" style="width:30%">
					<input type="text" name="attr_value" id="attr_value" placeholder="输入属性可能值，用逗号隔开" value="{$attr.value|default=''}" class="input-text" style="width:50%;margin-left: 5%;">
					<button onclick="attr_del({$goods.id})" type="button" class="btn btn-primary radius">删除</button>
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>详细内容：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<script id="goods_desc" name="goods_desc" type="text/plain" style="width:100%;height:450px;">{$goods.goods_desc|raw}</script>
				</div>
			</div>
			<div class="row cl">
				<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
					<button class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i>
						保存</button>
				</div>
			</div>
		</form>
	</div>

	<!--_footer 作为公共模版分离出去-->
	{include file="common/_footer" /}
	<!--/_footer /作为公共模版分离出去-->

	<!--请在下方写此页面业务相关的脚本-->
	<style type="text/css">
		.li123 {
			line-height: 30px;
			background: burlywood;
			display: inline-block;
			vertical-align: middle;
			padding: 0 8px;
		}
	</style>
	<script type="text/javascript" src="__MANAGE__lib/jquery.validation/1.14.0/jquery.validate.js"></script>
	<script type="text/javascript" src="__MANAGE__lib/jquery.validation/1.14.0/validate-methods.js"></script>
	<script type="text/javascript" src="__MANAGE__lib/jquery.validation/1.14.0/messages_zh.js"></script>
	<script type="text/javascript" src="__MANAGE__lib/ueditor/ueditor.config.js"></script>
	<script type="text/javascript" src="__MANAGE__lib/ueditor/ueditor.all.min.js"> </script>
	<script type="text/javascript" src="__MANAGE__lib/ueditor/lang/zh-cn/zh-cn.js"></script>
	<script type="text/javascript">
		$(function() {
			$('.skin-minimal input').iCheck({
				checkboxClass: 'icheckbox-blue',
				radioClass: 'iradio-blue',
				increaseArea: '20%'
			});
			$("#tab-system").Huitab({
				index: 0
			});
			$("#form-article-add").validate({
				rules: {
					goods_name: {
						required: true,
						rangelength: [3, 200]
					},
					cate_id: {
						required: true,
					},
					factoryid: {
						required: true,
					},
					markte_price: {
						required: true,
						number: true
					},
					money: {
						required: true,
						number: true
					},
					goods_desc: {
						required: true,
					},
					
				}
			});
			var ue = UE.getEditor('goods_desc');
		});
		function attr_del(id){
			layer.confirm('确认要删除产品属性吗？',function(index){
				$.post(
					"{:url('goods/ajax')}",
				{
					id:id,
					type:'attr_del',
				},
				function(result){
					if(result.code==1){
						window.location.reload();
						layer.msg('已删除!',{icon:1,time:1000});
					}else{
						layer.msg('删除失败!',{icon: 5,time:1000});
					}
				});	
			});
		}

		function onpic(e) {
			$(e).parent().find('.sp').html('您已经选择图片：' +$(e)[0].files[0].name).addClass('li123');
		}

		
	</script>
	<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>
